<?php

namespace Drupal\ssy_live_product\Entity;

class SsyLiveProduct extends \Entity {

  public $id;

  public $vid;

  public $uid;

  public $op_uid;

  public $created;

  public $changed;

  public $is_new_revision;

  public $product_id = 0;

  public $cover_img_url;

  public $name;

  public $price_type = 1;

  public $price = 0;

  public $price2 = 0;

  public $url = 0;

  public $third_party_appid = '';

  public $goods_id = 0;

  public $audit_id = 0;

  public $audit_status = 0;

  public $third_party_tag = 0;

  function __construct($values = []) {
    $this->is_new_revision = TRUE;
    parent::__construct($values, 'ssy_live_product');
  }

  public function save() {
    $this->changed = REQUEST_TIME;
    if (empty($this->created)) {
      $this->created = REQUEST_TIME;
    }

    $this->op_uid = $GLOBALS['user']->uid;
    if (empty($this->uid)) {
      $this->uid = $GLOBALS['user']->uid;
    }

    return parent::save();
  }

  function getMiniUrl() {
    return "pages/Goodsdetails/Goodsdetails?id={$this->product_id}&type=1";
  }


}
